export const timeFilter = (oldTime) => {
  const t = new Date(oldTime)
  // 获取oldTime的时间戳计算与现在的差（毫秒）
  const uploadHistory = Date.now() - t.getTime()
  // 转换成年月日时分
  const year = Math.floor(uploadHistory / (1000 * 3600 * 24 * 365))
  const month = Math.floor(uploadHistory / (1000 * 3600 * 24 * 30))
  const day = Math.floor(uploadHistory / (1000 * 3600 * 24 * 7))
  const hour = Math.floor(uploadHistory / (1000 * 3600))
  const minute = Math.floor(uploadHistory / (1000 * 60))
  if (year) {
    return `${year}年前`
  }
  if (month) {
    return `${month}月前`
  }
  if (day) {
    return `${day}天前`
  }
  if (hour) {
    return `${hour}小时前`
  }
  if (minute) {
    return `${month}分钟前`
  } else {
    return '刚刚'
  }
}
// export const f1 = () => { }

export default {
  install (Vue) {
    Vue.filter('timeFilter', timeFilter)
    // Vue.filter('f1', f1)
  }
}
// import {f1} xx
